package me.ereach.streams;

import java.util.Comparator;
import java.util.List;

public class Main07StreamSort {
    public static void main(String[] args) {
        List<Movie> movies = List.of(
                new Movie("b", 10),
                new Movie("a", 15),
                new Movie("c", 20)
        );

        System.out.println("===compareTo");
        movies.stream()
                .sorted((a, b) -> a.getTitle().compareTo(b.getTitle()))
                .forEach(m -> System.out.println(m.getTitle()));

        System.out.println("===Comparator & Method References");
        movies.stream()
                .sorted(Comparator.comparing(Movie::getTitle))
                .forEach(m -> System.out.println(m.getTitle()));

        System.out.println("===Comparator & Method References with desc");
        movies.stream()
                .sorted(Comparator.comparing(Movie::getTitle).reversed())
                .forEach(m -> System.out.println(m.getTitle()));

    }
}
